package com.woniuxy.joylife.manager.controller;

import com.woniuxy.joylife.manager.entity.EstatesEntity;
import com.woniuxy.joylife.manager.service.EstatesService;
import com.woniuxy.joylife.manager.utils.PageUtils;
import com.woniuxy.joylife.manager.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 房屋信息
 *
 * @author renxiang
 * @email 981405195@qq.com
 * @date 2020-05-13 02:47:54
 */
@RestController
@RequestMapping("manager/estates")
public class EstatesController {
    @Autowired
    private EstatesService estatesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("manager:estates:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = estatesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{blocId}")
    //@RequiresPermissions("manager:estates:info")
    public R info(@PathVariable("blocId") String blocId){
		EstatesEntity estates = estatesService.getById(blocId);

        return R.ok().put("estates", estates);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("manager:estates:save")
    public R save(@RequestBody EstatesEntity estates){
		estatesService.save(estates);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("manager:estates:update")
    public R update(@RequestBody EstatesEntity estates){
		estatesService.updateById(estates);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("manager:estates:delete")
    public R delete(@RequestBody String[] blocIds){
		estatesService.removeByIds(Arrays.asList(blocIds));

        return R.ok();
    }

}
